home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / utility.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  5.0 KB  |  179 lines

  1. #ifndef __STD_UTILITY__
  2. #define __STD_UTILITY__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * utility - Declarations for the Standard Library utility classes
  8.  *
  9.  * $Id: utility,v 1.21 1996/08/29 00:15:36 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * Copyright (c) 1994
  14.  * Hewlett-Packard Company
  15.  *
  16.  * Permission to use, copy, modify, distribute and sell this software
  17.  * and its documentation for any purpose is hereby granted without fee,
  18.  * provided that the above copyright notice appear in all copies and
  19.  * that both that copyright notice and this permission notice appear
  20.  * in supporting documentation.  Hewlett-Packard Company makes no
  21.  * representations about the suitability of this software for any
  22.  * purpose.  It is provided "as is" without express or implied warranty.
  23.  *
  24.  *
  25.  ***************************************************************************
  26.  *
  27.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  28.  * ALL RIGHTS RESERVED *
  29.  * The software and information contained herein are proprietary to, and
  30.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  31.  * intends to preserve as trade secrets such software and information.
  32.  * This software is furnished pursuant to a written license agreement and
  33.  * may be used, copied, transmitted, and stored only in accordance with
  34.  * the terms of such license and with the inclusion of the above copyright
  35.  * notice.  This software and information or any other copies thereof may
  36.  * not be provided or otherwise made available to any other person.
  37.  *
  38.  * Notwithstanding any other lease or license that may pertain to, or
  39.  * accompany the delivery of, this computer software and information, the
  40.  * rights of the Government regarding its use, reproduction and disclosure
  41.  * are as set forth in Section 52.227-19 of the FARS Computer
  42.  * Software-Restricted Rights clause.
  43.  * 
  44.  * Use, duplication, or disclosure by the Government is subject to
  45.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  46.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  47.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  48.  * P.O. Box 2328, Corvallis, Oregon 97339.
  49.  *
  50.  * This computer software and information is distributed with "restricted
  51.  * rights."  Use, duplication or disclosure is subject to restrictions as
  52.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  53.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  54.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  55.  * then the "Alternate III" clause applies.
  56.  *
  57.  **************************************************************************/
  58.  
  59. #include <stdcomp.h>
  60.  
  61. #ifndef _RWSTD_NO_NAMESPACE
  62. namespace std {
  63. #endif
  64.  
  65. #ifndef _RWSTD_NO_NAMESPACE
  66. namespace rel_ops {
  67. #endif
  68.  
  69. //
  70. // Operators
  71. //
  72.  
  73. template <class T>
  74. inline bool operator!=(const T& x, const T& y)
  75. {
  76.     return !(x == y);
  77. }
  78.  
  79. template <class T>
  80. inline bool operator>(const T& x, const T& y)
  81. {
  82.     return y < x;
  83. }
  84.  
  85. template <class T>
  86. inline bool operator<=(const T& x, const T& y)
  87. {
  88.     return !(y < x);
  89. }
  90.  
  91. template <class T>
  92. inline bool operator>=(const T& x, const T& y)
  93. {
  94.     return !(x < y);
  95. }
  96.  
  97. #ifndef _RWSTD_NO_NAMESPACE
  98. } /* End of namespace rel_ops */
  99. #endif
  100.  
  101. //
  102. // Pairs.
  103. //
  104.  
  105. template <class T1, class T2>
  106. struct pair
  107. {
  108.     typedef T1 first_type;
  109.     typedef T2 second_type;
  110.  
  111.     T1 first;
  112.     T2 second;
  113.     pair (const T1& a, const T2& b) : first(a), second(b) {}
  114.     pair () 
  115. #ifndef _RWSTD_NO_BUILT_IN_CTOR
  116. : first(T1()), second(T2()) 
  117. #endif
  118.     { ; }
  119.  
  120. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  121.     template <class U, class V> pair(const pair<U,V>& p) 
  122.     : first(p.first), second(p.second)
  123.     { ; }
  124. #endif
  125.  
  126.     ~pair () {;} // To avoid xlC warnings when destroy is called.
  127. };
  128.  
  129. template <class T1, class T2>
  130. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y)
  131.     return x.first == y.first && x.second == y.second; 
  132. }
  133.  
  134. template <class T1, class T2>
  135. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y)
  136.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  137. }
  138.  
  139. #ifndef _RWSTD_NO_NAMESPACE
  140. template <class T1, class T2>
  141. inline bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  142.     return !(x == y);
  143. }
  144.  
  145. template <class T1, class T2>
  146. inline bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y)
  147.     return y < x;
  148. }
  149.  
  150. template <class T1, class T2>
  151. inline bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  152.     return !(x < y);
  153. }
  154.  
  155. template <class T1, class T2>
  156. inline bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y)
  157.     return !(y < x);
  158. }
  159. #endif
  160.  
  161. template <class T1, class T2>
  162. inline pair<T1, T2> make_pair(const T1& x, const T2& y)
  163. {
  164.     return pair<T1, T2>(x, y);
  165. }
  166.  
  167. #ifndef _RWSTD_NO_NAMESPACE
  168. }
  169. #endif
  170.  
  171. #pragma option pop
  172. #endif /*__STD_UTILITY__*/
  173.